<?php
/**
 * 城市查询
 * RegionModel.php
 * @author yuexch
 * @createtime 2020/3/16 16:37
 */

namespace app\index\model;


use think\Model;

class RegionModel extends Model
{

    protected $name = 'region';

    /**
     * 返回城市列表数据
     * @param array $condition
     * @return array|PDOStatement|string|\think\Collection
     * @author yuexch
     * @createtime 2019/12/26 18:07
     */
    public function getAreaList($condition = [])
    {
        $ret = [];
        if ($condition) {
            try {
                $data = $this->where($condition)->cache(true)->select();
                if ($data) {
                    $ret = $data;
                }
            } catch (\Exception $e) {
                $ret = [];
            }
        }
        return $ret;
    }

    /**
     * 方法描述内容
     * @param array $condition
     * @return array|PDOStatement|string|Model|null
     * @author yuexch
     * @createtime 2019/12/26 18:07
     */
    public function getAreaInfo($condition = [])
    {
        $ret = [];
        if ($condition) {
            try {
                $data = $this->where($condition)->cache(true)->find();
                if ($data) {
                    $ret = $data;
                }
            } catch (\Exception $e) {
                $ret = [];
            }
        }
        return $ret;
    }
}